package com.tfy.liquor.dao;

import com.tfy.liquor.bean.FreightRegion;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Mapper
@Service
public interface FreightRegionDao {
    // 获取全部省级地址信息
    @Select("select * from freight_region where type=1")
    ArrayList<FreightRegion> getProvinceFreightRegion();

    // 根据父级编号获取下级地址信息
    @Select("select * from freight_region where pid=${pid}")
    ArrayList<FreightRegion> getFreightRegionByPid(int pid);

    // 添加行政区域数据
    @Insert("insert into freight_region values(${id}, ${pid}, '${name}', ${type}, ${code})")
    int addFreightRegion(FreightRegion freightRegion);

    // 根据id获取行政区域信息
    @Select("select * from freight_region where id=${id}")
    FreightRegion getFreightRegionById(Integer id);
}
